package com.findFish.fish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.fish.domain.FishHealth;
import com.findFish.fish.service.IFishHealthService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 鱼类健康监测Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/fish/health")
public class FishHealthController extends BaseController
{
    @Autowired
    private IFishHealthService fishHealthService;

    /**
     * 查询鱼类健康监测列表
     */
    @PreAuthorize("@ss.hasPermi('fish:health:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishHealth fishHealth)
    {
        startPage();
        List<FishHealth> list = fishHealthService.selectFishHealthList(fishHealth);
        return getDataTable(list);
    }

    /**
     * 导出鱼类健康监测列表
     */
    @PreAuthorize("@ss.hasPermi('fish:health:export')")
    @Log(title = "鱼类健康监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishHealth fishHealth)
    {
        List<FishHealth> list = fishHealthService.selectFishHealthList(fishHealth);
        ExcelUtil<FishHealth> util = new ExcelUtil<FishHealth>(FishHealth.class);
        util.exportExcel(response, list, "鱼类健康监测数据");
    }

    /**
     * 获取鱼类健康监测详细信息
     */
    @PreAuthorize("@ss.hasPermi('fish:health:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishHealthService.selectFishHealthById(id));
    }

    /**
     * 新增鱼类健康监测
     */
    @PreAuthorize("@ss.hasPermi('fish:health:add')")
    @Log(title = "鱼类健康监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishHealth fishHealth)
    {
        return toAjax(fishHealthService.insertFishHealth(fishHealth));
    }

    /**
     * 修改鱼类健康监测
     */
    @PreAuthorize("@ss.hasPermi('fish:health:edit')")
    @Log(title = "鱼类健康监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishHealth fishHealth)
    {
        return toAjax(fishHealthService.updateFishHealth(fishHealth));
    }

    /**
     * 删除鱼类健康监测
     */
    @PreAuthorize("@ss.hasPermi('fish:health:remove')")
    @Log(title = "鱼类健康监测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishHealthService.deleteFishHealthByIds(ids));
    }
}
